package client;

import org.openmuc.j60870.ClientConnectionBuilder;
import org.openmuc.j60870.Connection;

import java.io.IOException;
import java.net.InetAddress;

/**
 * @Author : 托马斯
 * @Date : 2025/6/27 8:47
 * @Description :
 */
public class Main {

    public static void main(String[] args) {
        try {
            String host = "127.0.0.1";
            int port = 1000;
            InetAddress address = InetAddress.getByName(host);
            Connection build = new ClientConnectionBuilder(address)
                    .setPort(port) // 默认2404
                    .setConnectionTimeout(1000) // 默认20秒
                    //.setReservedASduTypeDecoder(new CustomTypeDecoder()) // 自定义实现ASDU解码器
                     .setConnectionEventListener(new IEC104Listener()) // ASDU 数据接收监听
                    .build();
            build.startDataTransfer(); // 启动
        } catch (IOException e) {
            System.err.println("IEC104 连接失败：" + e.getMessage());
        }
    }

}
